package com.airnewslinkosky.ticket.ui.client;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

import com.airnewslinkosky.ticket.R;
import com.airnewslinkosky.ticket.ui.BaseActivity;
import com.airnewslinkosky.ticket.ui.Main;
import com.mobclick.android.MobclickAgent;

public class ClientCenter extends BaseActivity{
    private SharedPreferences sp;
	private String loginNameRe = "";
	private String isLoninOK = null;//是否登录
	private String autoLogin = null;//记着登录
	
	 private LinearLayout setClientLay,setPassengerLay;
	 private Button backBut;
	 
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.client_center);
		// 删除窗口背景
        getWindow().setBackgroundDrawable(null);
		activityList.add(this); 
		
		sp = getSharedPreferences("UserInfoB2B", Context.MODE_WORLD_WRITEABLE | Context.MODE_WORLD_READABLE);
		initConfig();
		
		setClientLay = (LinearLayout)findViewById(R.id.setClientLay);
		setPassengerLay = (LinearLayout)findViewById(R.id.setPassengerLay);
		
		OnClickListener b_ocl= new OnClickListener() { 
	    	public void onClick(View v) { 
	    		switch (v.getId()) {
	    		case R.id.setClientLay:
	    			Intent intentC = new Intent();
	    			intentC.setClass(ClientCenter.this, ClientSearch.class);
	    			startActivity(intentC);
	    			break;
	    		case R.id.setPassengerLay:
	    			Intent intentPd = new Intent();
	    			intentPd.setClass(ClientCenter.this, ClientContactsSearch.class);
	    			startActivity(intentPd);
	    			break;
	    		case R.id.backBut:
	    			Intent intentR = new Intent();
	    			intentR.setClass(ClientCenter.this, Main.class);
	    			Bundle bundle=new  Bundle();
	    			bundle.putString("loginName", loginNameRe);
	    			bundle.putString("isLoninOK", isLoninOK);
	    			bundle.putString("autoLogin", autoLogin);
	    			intentR.putExtras(bundle);
	    			setResult(RESULT_OK, intentR);
	    			finish();
					break;
	    		}
	    	}
		};
		
		backBut = (Button) findViewById(R.id.backBut);
		backBut.setOnClickListener(b_ocl);
		
		setClientLay = (LinearLayout) findViewById(R.id.setClientLay);
		setClientLay.setOnClickListener(b_ocl);
		setPassengerLay = (LinearLayout) findViewById(R.id.setPassengerLay);
		setPassengerLay.setOnClickListener(b_ocl);
	}
	
    //初始化配置
    private void initConfig() {
    	sp = getSharedPreferences("UserInfoB2B", 0);
        loginNameRe = sp.getString("loginName", "");
        isLoninOK = sp.getString("isLoninOK", null);
        autoLogin = sp.getString("isAutoLogin", null);
    }
    
	public void onResume() {     
		super.onResume();     
		MobclickAgent.onResume(this); 
	}  
	
	public void onPause() {     
		super.onPause();     
		MobclickAgent.onPause(this); 
	}  
}
